<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="frmTitle">
        <p:growl id="msgs" showDetail="false"/>
        <h:panelGrid columns="2" cellpadding="1">
            <h:outputText value="#{msgs.solicitacaoTitulo}" styleClass="fontTitle"/>
        </h:panelGrid>
    </h:form>

    <h:form id="frmSearch">

        <p:fieldset legend="Parametros">

            <h:panelGrid columns="2" id="pngSearch">    

                <p:outputLabel for="lblStatus" value="#{msgs.lblStatus}"/>
                <h:panelGrid columns="2">
                    <p:selectCheckboxMenu id="lblStatus" label="Selecione" value="#{solicitacaoReportMB.lsstatus}" style="width: 120px">
                        <f:selectItems value="#{solicitacaoReportMB.itemstatus}"/> 
                    </p:selectCheckboxMenu>
                </h:panelGrid>

                <h:panelGrid columns="2">
                    <p:commandButton id="btnBuscar" value="#{msgs.buscar}" action="#{solicitacaoReportMB.buscar}" ajax="false" update=":frmDataTable,:frmTotal"/>
                </h:panelGrid>
            </h:panelGrid>

        </p:fieldset>
    </h:form>
    
    <h:form id="frmTotal">
        <h:panelGrid columns="2" style="text-align: right; font-weight: bold">
        <h:outputLabel value="Total de registros"/>
        <h:outputLabel value="#{solicitacaoReportMB.strtotal}"/>
        </h:panelGrid>
    </h:form>
    
     <h:form id="frmDataTable">

        <p:fieldset legend="solicitações">

            <h:panelGrid width="100%">            
                
                <p:dataTable id="tbl" var="tbl" paginator="true" paginatorPosition="bottom" rowsPerPageTemplate="5,10,15" rows="10"
                             emptyMessage="#{msgs.msgTabelaVazia}" value="#{solicitacaoReportMB.lssolicitacao}">
                    <f:facet name="header">
                        <h:outputText value="#{msgs.solicitacaoTblTitulo}"/>                    
                    </f:facet>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.descricao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.modeloSolicitacao.descricao}"/>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.aluno}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.aluno.nome}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colDtCriacao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.dtcriacao}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Departamento atual"/>
                        </f:facet>
                        <h:outputText value="#{tbl.etapaatual.departamento.descricao}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colFuncionario}"/>
                        </f:facet>
                         <h:outputText value="#{tbl.funcionario.nome}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Prazo"/>
                        </f:facet>
                        <h:outputText value="#{solicitacaoReportMB.calculaData(tbl.dtcriacao,tbl)}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.status}"/>
                        </f:facet>
                        <h:outputText value="#{solicitacaoReportMB.strStatusLabel(tbl.status)}"/>
                    </p:column>

                </p:dataTable>

            </h:panelGrid>

        </p:fieldset>

    </h:form>
  
    <h:form id="frmPdf">
        <h:panelGrid>
            <p:commandLink styleClass="bottomLink" onclick="PrimeFaces.monitorDownload(start, stop)" actionListener="#{solicitacaoReportMB.generatePdfFile()}" ajax="false">
                <h:outputText value="Pdf"/>
                <p:fileDownload value="#{solicitacaoReportMB.file}" />  
            </p:commandLink>
        </h:panelGrid>
    </h:form>
    
    <p:dialog modal="true" widgetVar="statusDialog" header="Processando...">
        <p:graphicImage value="img/ajaxloadingbar.gif"/>
    </p:dialog>
        
</html>

